home *** CD-ROM | disk | FTP | other *** search
/ IRIX 6.4 Applications 1997 August / SGI IRIX 6.4 Applications 1997 August.iso / dist / mmailp.idb / usr / lib / Zmail / bin / mailp.z / mailp
Encoding:
Text File  |  1997-01-22  |  2.6 KB  |  125 lines

  1. #! /bin/sh
  2. #
  3. #  @(#)mailp 1.3 92/02/17
  4. #
  5. #  mailp, newsp, filep, digestp, filofaxp, timemanp and timesysp
  6. #  shell script de lancement de mp
  7. #  (mail/news/file/digest/filofax/time-manager/time-system pretty printer)
  8. #
  9. #  Original:   Bruno Pillard      - October 1988.
  10. #  Modified:   Rich Burridge      - June 1989.
  11. #  Revisited:  Larry W. Virden    - August, September 1990.
  12. #  Revisited:  Bruno Pillard      - September 1990.
  13. #  Revisited:  David W. Sanderson - August 1991.
  14.  
  15. BIN=BINDIR
  16.  
  17. #  NOTE: Banner printing is disabled below, by the inclusion of the -h
  18. #        switch to the lpr command. Most of the information that typically
  19. #        appears on the banner sheet, is output in the mp banners. If you
  20. #        wish to enable banner printing, then you should remove the -h switch.
  21.  
  22. PROG=mp
  23. case $BIN in
  24. /*)    PROG=$BIN/mp;;
  25. esac
  26. FLAGS=
  27. STDIN=
  28. LPARGS=
  29.  
  30. case $0 in
  31. *mailp)        ;;
  32. *newsp)     FLAGS=-a  ;;
  33. *digestp)   FLAGS=-d  ;;
  34. *filep)        FLAGS=-o; STDIN=-sstdin ;;
  35. *filofaxp)  FLAGS=-ff ;;
  36. *franklinp) FLAGS=-fp ;;
  37. *timemanp)  FLAGS=-tm ;;
  38. *timesysp)  FLAGS=-ts ;;
  39. *)             echo Unknown pretty printer: $0
  40.         exit ;;
  41. esac
  42.  
  43. # avoid using test - slow in v7 /bin/sh
  44. # while    [ $# -gt 0 ]
  45. for DUMMY in ${1+"$@"}
  46. do
  47.     case $1 in
  48.     # flags to pass through to mp
  49.     -F | -l | -A4)
  50.         FLAGS="$FLAGS $1"
  51.         shift
  52.         ;;
  53.     -s)    FLAGS="$FLAGS -s\"$2\""
  54.         STDIN=
  55.         shift;shift
  56.         ;;
  57.     -s*)    FLAGS="$FLAGS \"$1\""
  58.         STDIN=
  59.         shift
  60.         ;;
  61.     -W)    FLAGS="$FLAGS -W\"$2\""
  62.         shift;shift
  63.         ;;
  64.     -p)    FLAGS="$FLAGS -p\"$2\""
  65.         shift;shift
  66.         ;;
  67.     -c)    FLAGS="$FLAGS -c\"$2\""
  68.         shift;shift
  69.         ;;
  70.     -w)    FLAGS="$FLAGS -w\"$2\""
  71.         shift;shift
  72.         ;;
  73.     -W*|-p*|-c*|-w*)    FLAGS="$FLAGS \"$1\""
  74.                 shift
  75.                 ;;
  76.  
  77.     # allow both -d and -P to specify the printer name
  78.     -d|-P)    LPDEST="$2"
  79.         PRINTER="$LPDEST"
  80.         shift;shift
  81.         ;;
  82.     -d*|-P*)LPDEST=`echo "$1"|sed 's/^-.//'`
  83.         PRINTER="$LPDEST"
  84.         shift
  85.         ;;
  86.     -h)    LPARGS="$LPARGS -h"
  87.         shift
  88.         ;;
  89.  
  90.     # explicit end of arguments
  91.     --)    shift; break
  92.         ;;
  93.     -*)    LPARGS="$LPARGS \"$1\""
  94.         shift
  95.         ;;
  96.     # stop processing arguments with the first nondash argument
  97.     *)    break
  98.         ;;
  99.     esac
  100. done
  101.  
  102. # If LPDEST or PRINTER is already set in the environment, and no -d or -P
  103. # argument was given, then the appropriate variable will still affect the
  104. # appropriate printing command.
  105. if    [ -d /usr/spool/lp ]
  106. then    PRINT_CMD="lp  ${LPDEST+-d${LPDEST}}   -t"
  107. else    PRINT_CMD="lpr ${PRINTER+-P${PRINTER}} -J"
  108. fi
  109.  
  110. # for v in '*' '#' PROG STDIN FLAGS PRINT_CMD LPARGS
  111. # do    eval echo "\"$v\"" = \"\'\$$v\'\"
  112. # done
  113. # exit 0
  114.  
  115. case $# in
  116. 0)    eval $PROG $STDIN $FLAGS '|' ${PRINT_CMD}stdin $LPARGS
  117.     ;;
  118. *)    for FILE
  119.     do    eval $PROG $FLAGS $FILE | $PRINT_CMD$FILE $LPARGS
  120.     done
  121.     ;;
  122. esac
  123.  
  124. exit 0
  125.